<?php
namespace Models;
use Phalcon\Mvc\Model\Validator\PresenceOf;
class AlipayMenu extends BaseModel {
    public function validation()
    {
        $this->validate(new PresenceOf(array(
            'field' => 'keyword',
            'message' => '关键字为必填'
        )));
        $this->validate(new PresenceOf(array(
            'field' => 'title',
            'message' => '菜单名为必填'
        )));
        if ($this->validationHasFailed() == true) {
            return false;
        }
    }

    public function notSave()
    {
        //Obtain the flash service from the DI container
        $flash = $this->getDI()->getFlash();

        //Show validation messages
        foreach ($this->getMessages() as $message) {
            $flash->error($message);
        }
    }
}